package cn.lyf;

import cn.lyf.entity.BlogType;
import cn.lyf.entity.User;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@SpringBootApplication
public class BloggerDemoApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext ioc = SpringApplication.run(BloggerDemoApplication.class, args);
        PasswordEncoder passwordEncoder = ioc.getBean(PasswordEncoder.class);
        MongoTemplate mongoTemplate = ioc.getBean(MongoTemplate.class);
        User user = new User();
        user.setUsername("dog");
        user.setPassword(passwordEncoder.encode("123456"));
        user.setRole("ADM");
        user.setNickname("dog");
        mongoTemplate.insert(user);

        BlogType blogType = new BlogType();
        blogType.setNum(0);
        blogType.setTypename("首页技术区");
        mongoTemplate.insert(blogType);

        BlogType blogType2 = new BlogType();
        blogType2.setNum(0);
        blogType2.setTypename("大牛区");
        mongoTemplate.insert(blogType2);

    }


}
